
clear all; close all; clc;
R=100;
C=33e-6;
RC=R*C;

Tmod=1000*RC;
T=RC/100;
t=0:T:Tmod;


fmin=1/(Tmod/2);
fmax=2*(1/RC/2/pi);
f=fmin:((fmax-fmin)/100):fmax;
K=nan(1,length(f));
for j=1:length(f);
    E=sin(2*pi*f(j)*t);

U=nan(1,length(t));
dU=nan(1,length(t));

U(1)=E(1); dU(1)=0;


 for k=2:length(t);
    U(k)=U(k-1)*dU(k-1)*T;
    dU(k)=(E(k)-U(k))/RC;
    
 end  
Us=U(fix(end/2):end);
K(j)=(max(Us)-min(Us))/2;
end

    figure;
    plot(f,20*log10(K))
    xlabel('f,Hz');
    ylabel('K');